package model;

/**
 * This class hold all the data about an individual Park. 
 * In addition, it holds the static fields and methods for 
 * districts and regions.
 * 
 * @author Ken Norton
 * 
 * James Gunter made the original empty class and removed
 * some superfluous fields and methods.
 */
public class Park {
  
  /*
   * =====================================================
   * Instance fields
   * =====================================================
   */
  
  /**
   * The name of the Park.
   * 
   * invariant: not null.
   */
  private String my_name;
  
  /**
   * The address of the Park.
   * 
   * invariant: not null.
   */
  private String my_address;
  
  /**
   * The district the Park is in.
   * 
   * invariant: not null.
   */
  private String my_district;
  
  /**
   * The region the Park is in. 
   * 
   * invariant: not null.
   */
  private String my_region;
  
  /**
   * The Park Manager for this Park.
   * 
   * invariant: not null.
   */
  private User my_park_manager;
  
  /**
   *  No args constructor for a Park object.
   *  
   *  pre:  none.
   *  
   *  post: my_name is non-null.
   *  post: my_address is non-null.
   *  post: my_district is non-null.
   *  post: my_region is non-null.
   *  post: my_park_manager is non-null.
   */
  public Park() {
    my_name = "";
    my_address = "";
    my_district = "";
    my_region = "";
    my_park_manager = new User("", "", Role.PARK_MANAGER);
  }
  
  /**
   * Constructs a new Park object.
   * 
   * @param the_name The Park's name.
   * @param the_address The Park's address.
   * @param the_district The Park's district.
   * @param the_region The Park's region.
   * 
   * pre: the_name is non-null.
   * pre: the_address is non-null.
   * pre: the_district is non-null.
   * pre: the_region is non-null.
   * pre: the_park_manager is non-null.
   * 
   * post: my_name is set to the_name.
   * post: my_address is set to the_address.
   * post: my_district is set to the_district.
   * post: my_region is set to the_region.
   * post: my_park_manager is set to the_park_manager.
   */
  public Park(final String the_name, 
      final String the_address, final String the_district, 
      final String the_region, 
      final User the_park_manager) {
    my_name = the_name;
    my_address = the_address;
    my_district = the_district;
    my_region = the_region;
    my_park_manager = the_park_manager;
  }
  
  /*
   * =====================================================
   * Instance methods
   * =====================================================
   */
  
  /**
   * Compares this Park with another object to see if they 
   * are equal.
   * 
   * @param the_object The Object to be checked for 
   * equality.
   * @return True if the Object passed in is equal to this 
   * one.
   * 
   * pre:  none.
   * 
   * post: No modifications.
   */
  @Override
  public boolean equals(final Object the_other) {
    boolean is_equal = false;
    if (the_other != null && 
        the_other.getClass() == getClass()) {
      Park other = (Park) the_other;
      is_equal = my_name.equals(other.getName());
      is_equal = (is_equal && 
          my_address.equals(other.getAddress()));
      is_equal = (is_equal && 
          my_district.equals(other.getDistrict()));
      is_equal = (is_equal && 
          my_region.equals(other.getRegion()));
      is_equal = (is_equal && 
          my_park_manager.equals(other.getParkManager()));
    }
    return is_equal;
  }
  
  /**
   * Generates the hashCode for this Park.
   * 
   * @return An integer hash code.
   * 
   * pre:  none:
   * 
   * post: No modifications.
   */
  @Override
  public int hashCode() {
    return toString().hashCode();
  }
  
  /**
   * Generates the String representation of this Park.
   * 
   * @return The String representation of this Park.
   * 
   * pre:  none.
   * 
   * post: No modifications.
   */
  @Override
  public String toString() {
    StringBuilder str = new StringBuilder();
    str.append(my_name);
    str.append("\n");
    str.append(my_address);
    str.append("\n");
    str.append(my_district);
    str.append("\n");
    str.append(my_region);
    str.append("\n");
    str.append(my_park_manager.getUserEmail());
    return str.toString();
  }
  
  /*
   * =====================================================
   * Accessors and mutators
   * =====================================================
   */  
  
  /**
   * Sets the name of the Park.
   * 
   * @param the_name A String with the name of the Park.
   * 
   * pre:  the_name is a non-null String.
   * 
   * post: my_name is set to the_name.
   */
  public void setName(final String the_name) {
    my_name = the_name;
  }
  
  /**
   * Gets the name of the Park.
   * 
   * @return Returns a String with the name of the Park.
   * 
   * pre:  none.
   * 
   * post: No modifications.
   */
  public String getName() {
    return my_name;
  }
  
  /**
   * Sets the address of the Park.
   * 
   * @param the_address A String with the address of the 
   * Park.
   * 
   * pre: the_address is a non-null String.
   * 
   * post: my_address is set to the_address.
   */
  public void setAddress(final String the_address) {
    my_address = the_address;
  }
  
  /**
   * Gets the address of the Park.
   * 
   * @return A String with the address of the Park.
   * 
   * pre:  none.
   * 
   * post: No modifications.
   */
  public String getAddress() {
    return my_address;
  }
  
  /**
   * Sets the district for this Park.
   * 
   * @param the_district A String with the district.
   * 
   * pre: the_district is a non-null String.
   * 
   * post: my_district is set to the_district.
   */
  public void setDistrict(final String the_district) {
    my_district = the_district;
  }
  
  /**
   * Gets the district for this Park.
   * 
   * @return A String with the district for this Park.
   * 
   * pre:  none.
   * 
   * post: No modifications.
   */
  public String getDistrict() {
    return my_district;
  }
  
  /**
   * Sets the region for this Park.
   * 
   * @param the_region A String with the region for this 
   * Park.
   * 
   * pre:  the_region is a non-null String.
   * 
   * post: my_region is set to the_region.
   */
  public void setRegion(final String the_region) {
    my_region = the_region;
  }
  
  /**
   * Gets the region for this Park.
   * 
   * @return Returns a String with the region for this Park.
   * 
   * pre: none.
   * 
   * post: No modifications.
   */
  public String getRegion() {
    return my_region;
  }
  
  /**
   * Sets the ParkManager for this Park.
   * 
   * @param the_park_manager A User that is a ParkManager.
   * 
   * pre:  the_park_manager is a non-null User.
   * pre:  the_park_manager has the Role of PARK_MANAGER.
   * 
   * post: my_park_manager is sset to the_park_manager.
   */
  public void setParkManager(final User the_park_manager) {
    my_park_manager = the_park_manager;
  }
  
  /**
   * Gets the ParkManager for this Park.
   * 
   * @return The ParkManager for this park.
   * 
   * pre: none.
   * 
   * post: No modificatons.
   */
  public User getParkManager() {
    return my_park_manager;
  }
}
